//
//  CellOfActivityMessage.m
//  UI_OATest0520
//
//  Created by apple on 16/5/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "TableViewCell.h"
#import "Model.h"


@interface TableViewCell ()

@property (retain, nonatomic) IBOutlet UIView *backViewFirst;
@property (retain, nonatomic) IBOutlet UIView *backViewSecond;
@property (retain, nonatomic) IBOutlet UILabel *headerTitle;
@property (retain, nonatomic) IBOutlet UILabel *lableOfTime;
@property (retain, nonatomic) IBOutlet UILabel *lableOfPlace;
@property (retain, nonatomic) IBOutlet UILabel *lableOfType;
@property (retain, nonatomic) IBOutlet UILabel *numberOfInterest;
@property (retain, nonatomic) IBOutlet UILabel *numberOfJoin;
@property (retain, nonatomic) IBOutlet UIImageView *viewOfPic;



@end

@implementation TableViewCell




- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    [self addLayerAttributeToView];
    
}


#pragma mark - Private Function

- (void)addLayerAttributeToView{

    self.backViewFirst.layer.cornerRadius = 10;
//    self.backViewFirst.layer.borderWidth = 1;
//    self.backViewFirst.layer.masksToBounds = YES;
    
    //阴影部分 , 不显示
    self.backViewFirst.layer.shadowOpacity = 1;
    self.backViewFirst.layer.shadowColor = [UIColor grayColor].CGColor;
    self.backViewFirst.layer.shadowOffset = CGSizeMake(0, 3);
    self.backViewFirst.layer.shadowRadius = 2;
    
    self.backViewSecond.layer.cornerRadius = 10;
    self.backViewSecond.layer.masksToBounds = YES;

}

- (void)setModel:(Model *)model{

    if (model != _model) {
        
        [_model release];
        _model  = [model retain];
        
    }

    
    self.headerTitle.text = model.title;
    self.lableOfTime.text = [self getTimeTextWithBeginTime:model.begin_time EndTime:model.end_time];
    self.lableOfPlace.text = model.address;
    self.lableOfType.text = model.category_name;
    self.numberOfInterest.text = [NSString stringWithFormat:@"%@",model.wisher_count];
    self.numberOfJoin.text = [NSString stringWithFormat:@"%@",model.participant_count];



}

- (NSString *)getTimeTextWithBeginTime:(NSString *)begin
                         EndTime:(NSString *)end{

    NSRange range = NSMakeRange(5, 11);
    
    begin = [begin substringWithRange:range];
    end = [end substringWithRange:range];
    
    return [[begin stringByAppendingString:@"--"] stringByAppendingString:end];

}


- (void)dealloc {
    [_backViewFirst release];
    [_backViewSecond release];
    [_headerTitle release];
    [_lableOfTime release];
    [_lableOfPlace release];
    [_lableOfType release];
    [_numberOfInterest release];
    [_numberOfJoin release];
    [_viewOfPic release];
    [_model release];

    [super dealloc];
}
@end
